package com.ke.forum.forumapi.controller;


import com.ke.forum.common.annotation.JwtIgnore;
import com.ke.forum.common.common.Result;
import com.ke.forum.forumapi.service.UserService;
import com.ke.forum.mbg.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 珂
 * @since 2022-05-22
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @JwtIgnore
    @PostMapping("signUp")
    public Result signUp(@RequestBody @Validated User user){
        return userService.signUp(user);
    }

    @JwtIgnore
    @PostMapping("login")
    public  Result login(@RequestBody @Validated User user){
        return userService.login(user);
    }

    @GetMapping("getUserInfo")
    public Result getUserInfo(@RequestParam(required = false) String uuid,@RequestParam(required = false) Boolean refresh){
        return userService.getUserInfo(uuid,refresh);
    }

    @PostMapping("updateUserInfo")
    public Result updateUserInfo(@RequestBody @Validated User user){
        return userService.updateUserInfo(user);
    }

    @GetMapping("listStarUserInfo")
    public Result listStarUserInfo(@RequestParam(value = "current",defaultValue = "1") Integer current){
        return userService.listStarUserInfo(current);
    }

    @GetMapping("listFanUserInfo")
    public Result listFanUserInfo(@RequestParam(value = "current",defaultValue = "1") Integer current){
        return userService.listFanUserInfo(current);
    }
}

